// Copyright (c) 2021 CINN Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <isl/cpp.h>

#include <string>
#include <vector>

#include "paddle/cinn/poly/dim.h"

namespace cinn {
namespace poly {

struct Domain {
  //! The id of the statement.
  std::string id;
  //! The dimensions.
  std::vector<Dim> dims;
  //! The parameters.
  std::vector<Dim> params;

  //! The ISL context.
  isl::ctx ctx;

  Domain(isl::ctx ctx, std::string id, std::vector<Dim> dims)
      : ctx(ctx), id(std::move(id)), dims(std::move(dims)) {
    ExtractParams();
  }

  //! The ISL format representation, such as '{ S[i]: 0<=i<=20 }'.
  std::string __str__() const;

  //! Get the isl domain.
  isl::set to_isl() const;

 private:
  //! Extract the parameters from dims.
  void ExtractParams();
};

}  // namespace poly
}  // namespace cinn
